package two.chapter_1.c1_3;

import edu.princeton.cs.algs4.StdOut;


public class Ex1_3_31 {

    public static void main(String[] args) {



        addLast();



    }

    private static void addLast(){
        DoubleLinkedList<String> list=new DoubleLinkedList<>();
        list.addLast("g");
        list.addLast("f");
        list.addLast("e");
        list.addLast("d");
        list.addLast("c");
        list.addLast("b");
        list.addLast("a");
        for (String item:list) {
            StdOut.print(item);   // gfedcba
        }
        StdOut.println();
        StdOut.println(list.size());
    }
    private static void addFirst(){
        DoubleLinkedList<String> list=new DoubleLinkedList<>();
        list.addFirst("g");
        list.addFirst("f");
        list.addFirst("e");
        list.addFirst("d");
        list.addFirst("c");
        list.addFirst("b");
        list.addFirst("a");
        for (String item:list) {
            StdOut.print(item);   // abcdefg
        }
        StdOut.println();
        StdOut.println(list.size());
    }


}
